import request, { type ListQuery, type ListResponse } from "@/utils/request";

const FORUM_BASE_URL = "/api";

export const ForumAPI = {
  getForumList: (params?: ForumListQuery) => {
    return request.get<any, ListResponse<ForumForm>>(`${FORUM_BASE_URL}/global/supplier/`, {
      params,
    });
  },
  addForum: (data: Partial<ForumForm>) => {
    return request.post(`${FORUM_BASE_URL}/global/supplier/`, data);
  },
  updateForum: (data: Partial<ForumForm>) => {
    return request.put(`${FORUM_BASE_URL}/global/supplier/${data.id}/`, data);
  },
  deleteForum: (id: number) => {
    return request.delete(`${FORUM_BASE_URL}/global/supplier/${id}/`);
  },
};

export type ForumListQuery = {} & ListQuery;

export type ForumForm = {
  id?: number;
  name: string;
  industry: string;
  context: string;
  humans: ParticipantType[];
};

export type ParticipantType = {
  name: string;
  position: string;
  phone: string;
};

export default ForumAPI;
